package cn.iocoder.yudao.module.custom.dal.mysql.merchant;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.custom.dal.dataobject.merchant.MerchantDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.custom.controller.admin.merchant.vo.*;

/**
 * 商户信息 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface MerchantMapper extends BaseMapperX<MerchantDO> {

    default PageResult<MerchantDO> selectPage(MerchantPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<MerchantDO>()
                .eqIfPresent(MerchantDO::getMerchantId, reqVO.getMerchantId())
                .likeIfPresent(MerchantDO::getMerchantName, reqVO.getMerchantName())
                .eqIfPresent(MerchantDO::getMerchantStatus, reqVO.getMerchantStatus())
                .likeIfPresent(MerchantDO::getServiceProviderName, reqVO.getServiceProviderName())
                .likeIfPresent(MerchantDO::getLoginUsername, reqVO.getLoginUsername())
                .likeIfPresent(MerchantDO::getContactPersonName, reqVO.getContactPersonName())
                .eqIfPresent(MerchantDO::getIdentityCardNumber, reqVO.getIdentityCardNumber())
                .eqIfPresent(MerchantDO::getPhoneNumber, reqVO.getPhoneNumber())
                .eqIfPresent(MerchantDO::getEmail, reqVO.getEmail())
                .eqIfPresent(MerchantDO::getAddress, reqVO.getAddress())
                .eqIfPresent(MerchantDO::getQq, reqVO.getQq())
                .likeIfPresent(MerchantDO::getWebsiteName, reqVO.getWebsiteName())
                .eqIfPresent(MerchantDO::getWebsiteUrl, reqVO.getWebsiteUrl())
                .eqIfPresent(MerchantDO::getCustomerServicePhone, reqVO.getCustomerServicePhone())
                .eqIfPresent(MerchantDO::getFirstLevelCategory, reqVO.getFirstLevelCategory())
                .eqIfPresent(MerchantDO::getSecondLevelCategory, reqVO.getSecondLevelCategory())
                .eqIfPresent(MerchantDO::getThirdLevelCategory, reqVO.getThirdLevelCategory())
                .likeIfPresent(MerchantDO::getLegalPersonName, reqVO.getLegalPersonName())
                .eqIfPresent(MerchantDO::getLegalPersonPhone, reqVO.getLegalPersonPhone())
                .eqIfPresent(MerchantDO::getLegalPersonIdCardNumber, reqVO.getLegalPersonIdCardNumber())
                .betweenIfPresent(MerchantDO::getLegalPersonIdCardExpiryDate, reqVO.getLegalPersonIdCardExpiryDate())
                .eqIfPresent(MerchantDO::getBusinessLicenseNumber, reqVO.getBusinessLicenseNumber())
                .betweenIfPresent(MerchantDO::getBusinessLicenseExpiryDate, reqVO.getBusinessLicenseExpiryDate())
                .eqIfPresent(MerchantDO::getPaymentNumber, reqVO.getPaymentNumber())
                .likeIfPresent(MerchantDO::getAccountName, reqVO.getAccountName())
                .eqIfPresent(MerchantDO::getSettlementAccount, reqVO.getSettlementAccount())
                .likeIfPresent(MerchantDO::getBankName, reqVO.getBankName())
                .eqIfPresent(MerchantDO::getAccountType, reqVO.getAccountType())
                .eqIfPresent(MerchantDO::getProvince, reqVO.getProvince())
                .eqIfPresent(MerchantDO::getCity, reqVO.getCity())
                .eqIfPresent(MerchantDO::getCounty, reqVO.getCounty())
                .eqIfPresent(MerchantDO::getBankBranch, reqVO.getBankBranch())
                .eqIfPresent(MerchantDO::getRateDescription, reqVO.getRateDescription())
                .orderByDesc(MerchantDO::getId));
    }

    default List<MerchantDO> selectList(MerchantExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<MerchantDO>()
                .eqIfPresent(MerchantDO::getMerchantId, reqVO.getMerchantId())
                .likeIfPresent(MerchantDO::getMerchantName, reqVO.getMerchantName())
                .eqIfPresent(MerchantDO::getMerchantStatus, reqVO.getMerchantStatus())
                .likeIfPresent(MerchantDO::getServiceProviderName, reqVO.getServiceProviderName())
                .likeIfPresent(MerchantDO::getLoginUsername, reqVO.getLoginUsername())
                .likeIfPresent(MerchantDO::getContactPersonName, reqVO.getContactPersonName())
                .eqIfPresent(MerchantDO::getIdentityCardNumber, reqVO.getIdentityCardNumber())
                .eqIfPresent(MerchantDO::getPhoneNumber, reqVO.getPhoneNumber())
                .eqIfPresent(MerchantDO::getEmail, reqVO.getEmail())
                .eqIfPresent(MerchantDO::getAddress, reqVO.getAddress())
                .eqIfPresent(MerchantDO::getQq, reqVO.getQq())
                .likeIfPresent(MerchantDO::getWebsiteName, reqVO.getWebsiteName())
                .eqIfPresent(MerchantDO::getWebsiteUrl, reqVO.getWebsiteUrl())
                .eqIfPresent(MerchantDO::getCustomerServicePhone, reqVO.getCustomerServicePhone())
                .eqIfPresent(MerchantDO::getFirstLevelCategory, reqVO.getFirstLevelCategory())
                .eqIfPresent(MerchantDO::getSecondLevelCategory, reqVO.getSecondLevelCategory())
                .eqIfPresent(MerchantDO::getThirdLevelCategory, reqVO.getThirdLevelCategory())
                .likeIfPresent(MerchantDO::getLegalPersonName, reqVO.getLegalPersonName())
                .eqIfPresent(MerchantDO::getLegalPersonPhone, reqVO.getLegalPersonPhone())
                .eqIfPresent(MerchantDO::getLegalPersonIdCardNumber, reqVO.getLegalPersonIdCardNumber())
                .betweenIfPresent(MerchantDO::getLegalPersonIdCardExpiryDate, reqVO.getLegalPersonIdCardExpiryDate())
                .eqIfPresent(MerchantDO::getBusinessLicenseNumber, reqVO.getBusinessLicenseNumber())
                .betweenIfPresent(MerchantDO::getBusinessLicenseExpiryDate, reqVO.getBusinessLicenseExpiryDate())
                .eqIfPresent(MerchantDO::getPaymentNumber, reqVO.getPaymentNumber())
                .likeIfPresent(MerchantDO::getAccountName, reqVO.getAccountName())
                .eqIfPresent(MerchantDO::getSettlementAccount, reqVO.getSettlementAccount())
                .likeIfPresent(MerchantDO::getBankName, reqVO.getBankName())
                .eqIfPresent(MerchantDO::getAccountType, reqVO.getAccountType())
                .eqIfPresent(MerchantDO::getProvince, reqVO.getProvince())
                .eqIfPresent(MerchantDO::getCity, reqVO.getCity())
                .eqIfPresent(MerchantDO::getCounty, reqVO.getCounty())
                .eqIfPresent(MerchantDO::getBankBranch, reqVO.getBankBranch())
                .eqIfPresent(MerchantDO::getRateDescription, reqVO.getRateDescription())
                .orderByDesc(MerchantDO::getId));
    }

}
